package leetcode.每日一题;

import org.junit.Test;

import java.util.*;

/**
 * @author ：zsy
 * @date ：Created 2022/1/7 13:05
 * @description：https://leetcode-cn.com/problems/maximum-nesting-depth-of-the-parentheses/
 */
public class 括号的最大嵌套深度 {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(solution.maxDepth("(1)+((2))+(((3)))"));
    }


    class Solution {
        public int maxDepth(String s) {
            int lCount = 0;
            int max = 0;
            for (char c : s.toCharArray()) {
                if (c == '(') {
                    lCount++;
                    max = Math.max(max, lCount);
                } else if (c == ')') {
                    lCount--;
                }
            }
            return max;
        }
    }
}
